
var Grid = cc.Class({
    extends: cc.Component,

    properties: {
        colorList: {
            default: [],
            type: [cc.Color]
        },

        colorDefault: {
            default: null,
            type: cc.color,
        },
        

        label: {
            default: null,
            type: cc.Label,
        }
    },

    statics: {
        colorTotal: 5,
        getColorWithRandom: function () {
            return Math.floor(Math.random() * Grid.colorTotal)
        }
    },

    onLoad: function () {
        
    },

    setFillColor: function (index, x, y) {
        this.label.string = "" + x + "," + y;
        var color = null;
        if (index == undefined || index < 0 || index > this.colorList.length)
            color = this.colorDefault;
        else 
            color = this.colorList[index];
            
        this.getComponent(cc.Sprite).node.color = color;
    }
});
